package com.cloudwebrtc.voip.sipenginev2.impl;

import com.cloudwebrtc.voip.sipenginev2.RegistrationEventListener;
import com.cloudwebrtc.voip.sipenginev2.RegistrationManager;
import com.cloudwebrtc.voip.sipenginev2.SipProfile;

public class RegistrationManagerImpl implements RegistrationManager {
	//implement for RegistrationManager_JNI.cpp
	private long nativePtr = 0;
	private native void MakeRegister(long nativePtr, long profilePtr);
	private native void MakeDeRegister(long nativePtr, long profilePtr);
	private native void RefreshRegistration(long nativePtr, long profilePtr);
	private native void RegisterRegistrationObserver(long nativePtr, RegistrationEventListener observer);
	private native void DeRegisterRegistrationObserver(long nativePtr);
	private native void SetNetworkReachable(long nativePtr, boolean yesno);
	private native boolean ProfileIsRegistered(long nativePtr, long profilePtr);
	
	public RegistrationManagerImpl(long aNativePtr)
	{
		nativePtr = aNativePtr;
	}

	@Override
	public void MakeRegister(SipProfile sip_profile) {
		SipProfileImpl sip_profile_impl = (SipProfileImpl)sip_profile;
		MakeRegister(nativePtr,sip_profile_impl.GetNativePtr());
	}

	@Override
	public void MakeDeRegister(SipProfile sip_profile) {
		SipProfileImpl sip_profile_impl = (SipProfileImpl)sip_profile;
		MakeDeRegister(nativePtr,sip_profile_impl.GetNativePtr());
	}

	@Override
	public void RefreshRegistration(SipProfile sip_profile) {
		SipProfileImpl sip_profile_impl = (SipProfileImpl)sip_profile;
		RefreshRegistration(nativePtr,sip_profile_impl.GetNativePtr());
	}

	@Override
	public void RegisterRegistrationObserver(RegistrationEventListener observer) {
		RegisterRegistrationObserver(nativePtr,observer);
	}

	@Override
	public void DeRegisterRegistrationObserver() {
		DeRegisterRegistrationObserver(nativePtr);
	}

	@Override
	public void SetNetworkReachable(boolean yesno) {
		SetNetworkReachable(nativePtr,yesno);
	}
	
	@Override
	public boolean ProfileIsRegistered(SipProfile sip_profile)
	{
		SipProfileImpl sip_profile_impl = (SipProfileImpl)sip_profile;
		return ProfileIsRegistered(nativePtr,sip_profile_impl.GetNativePtr());
	}
}
